package com.aruba.rtmppushapplication.push.params;

/**
 * 视频参数
 * Created by aruba on 2021/1/12.
 */
public class VideoParams {
    //帧数
    private int fps;
    private int videoWidth;
    private int videoHeight;
    //码率
    private int bitrate;
    private int cameraId;

    private VideoParams(int videoWidth, int videoHeight, int cameraId) {
        this.videoWidth = videoWidth;
        this.videoHeight = videoHeight;
        this.cameraId = cameraId;
    }

    public int getFps() {
        return fps;
    }

    public void setFps(int fps) {
        this.fps = fps;
    }

    public int getVideoWidth() {
        return videoWidth;
    }

    public void setVideoWidth(int videoWidth) {
        this.videoWidth = videoWidth;
    }

    public int getVideoHeight() {
        return videoHeight;
    }

    public void setVideoHeight(int videoHeight) {
        this.videoHeight = videoHeight;
    }

    public int getBitrate() {
        return bitrate;
    }

    public void setBitrate(int bitrate) {
        this.bitrate = bitrate;
    }

    public int getCameraId() {
        return cameraId;
    }

    public void setCameraId(int cameraId) {
        this.cameraId = cameraId;
    }

    public static class Builder {
        private int fps = 25;
        private int videoWidth = -1;
        private int videoHeight = -1;
        private int bitrate = 480000;
        private int cameraId = -1;

        public Builder fps(int fps) {
            this.fps = fps;
            return this;
        }

        public Builder videoSize(int videoWidth, int videoHeight) {
            this.videoHeight = videoHeight;
            this.videoWidth = videoWidth;
            return this;
        }

        public Builder bitrate(int bitrate) {
            this.bitrate = bitrate;
            return this;
        }

        public Builder cameraId(int cameraId) {
            this.cameraId = cameraId;
            return this;
        }

        public VideoParams build() {
            if (videoWidth == -1 || videoHeight == -1 || cameraId == -1) {
                throw new RuntimeException("videoWidth,videoHeight,cameraId must be config");
            }
            VideoParams videoParams = new VideoParams(videoWidth, videoHeight, cameraId);
            videoParams.setBitrate(bitrate);
            videoParams.setFps(fps);

            return videoParams;
        }
    }
}
